import ServiceBase from '../base';
import {ProjectPageProxy} from '../proxies/project-page-proxy';
import ProjectModelProxy from '../proxies/ProjectModelProxy';
import * as proxy from '../proxy';
// import QuotaProxy from '../proxies/quota-proxy';

const GET_PROJECTS = '/accounts';

class ProjectService extends ServiceBase {
    // getUserProjects = (accountId) => {
    //   let promise = super.get(GET_PROJECTS + `/${accountId}/members/me/projects`);
    //   return proxy.httpResultProxy(promise, ProjectPageProxy);
    // };
    getUserProjects = (accountId) => {
        let promise = super.get({
            url: GET_PROJECTS + `/${accountId}/projects`,
        });
        return proxy.httpResultProxy(promise, ProjectPageProxy);
    };
    getUserProjectByProjectId = (data) => {
        let promise = super.get({
            url: GET_PROJECTS + `/${data.accountId}/projects/${data.projectId}`,
        });
        return proxy.httpResultProxy(promise, ProjectModelProxy);
    };
    getProjectPaging = (data) => {
        let promise = super.get({
            url: GET_PROJECTS + `/${data.accountId}/projects`,
            params: data.data,
        });
        return proxy.httpResultProxy(promise, ProjectPageProxy);
    };
    postProject = (data) => {
        let promise = super.post({
            url: GET_PROJECTS + `/${data.accountId}/projects`,
            data,
        });
        return proxy.httpResultProxy(promise, ProjectModelProxy);
    };
    putProject = (data) => {
        let promise = super.put({
            url: GET_PROJECTS + `/${data.accountId}/projects/${data.projectId}`,
            data,
        });
        return proxy.httpResultProxy(promise, ProjectModelProxy);
    };
    deleteProject = (data) => {
        let promise = super.put({
            url: GET_PROJECTS + `/${data.accountId}/projects/${data.projectId}/state`,
            data: {active: false},
        });
        return proxy.httpResultProxy(promise);
    };
    activeProject = (data) => {
        let promise = super.put({
            url: GET_PROJECTS + `/${data.accountId}/projects/${data.projectId}/state`,
            data: {active: true},
        });
        return proxy.httpResultProxy(promise);
    };
    // projectQuota = (data) => {
    //   let promise = super.get(GET_PROJECTS + `/${data.accountId}/projects/${data.projectId}/quota`);
    //   return proxy.httpResultProxy(promise, QuotaProxy);
    // };
}

export {ProjectService};
